<template>
  <el-dropdown @command="changLanguage">
    <span class="el-dropdown-link">
      <svg-icon
        icon-class="language"
        style="width:22px;height:22px;margin:0 16px 8px 0;color:#fff ;cursor: pointer;"
      >
      </svg-icon>
    </span>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item :disabled="$i18n.locale == 'zh'" command="zh"
        >中文</el-dropdown-item
      >
      <el-dropdown-item :disabled="$i18n.locale == 'en'" command="en"
        >English</el-dropdown-item
      >
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
import Cookies from 'js-cookie'
export default {
  data () {
    return {}
  },
  methods: {
    changLanguage (type) {
      console.log(type)
      // 改变语言
      this.$i18n.locale = type
      // 存到本地
      Cookies.set('lang', type)
      this.$router.go(0)
    }
  }
}
</script>

<style></style>
